import type { ApiLogBo } from './type'
import type { ApiDetail } from '@/api/api-manage/detail'

export function generateApiLog(
  apiInfo: ApiDetail,
  startDateTime: string,
  endDateTime: string,
  duration: number,
  requestUnit: string,
  resResult: string,
  resCode: number,
  method: string
) {
  const log: ApiLogBo = {
    apiName: apiInfo.apiName,
    apiId: String(apiInfo.id),
    apiPath: apiInfo.requestPath,
    apiType: apiInfo.apiType,
    requestTime: startDateTime,
    requestUnit: requestUnit,
    requestIp: null,
    responseTime: duration,
    responseResult: resResult,
    code: resCode,
    method: method,
    startTime: startDateTime,
    endTime: endDateTime,
    requestBody: '',
    responseBody: '',
  }
  return log
}
